package service

import (
	"context"
	"mygf2/internal/model/entity"

	"github.com/gogf/gf/v2/frame/g"
)

var (
	VideoSourceMap = g.Map{
		"auto":     "自动适配",
		"douyin":   "抖音",
		"kuaishou": "快手",
		"xigua":    "西瓜",
	}
	ServiceMapper = map[string]GatherService{
		"douyin":   &DouyinService,
		"kuaishou": &KuaishouService,
		"xigua":    &XiguaService,
	}
	UserAgent       = "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1"
	Kuaishouheaders = map[string]string{
		//"Accept":                    "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
		"Content-Type": "text/html; charset=utf-8",
		//"Accept-Encoding":           "gzip, deflate, br",
		//"Accept-Language":           "zh-CN,zh;q=0.9",
		//"Connection":                "keep-alive",
		//"Host": "v.kuaishou.com",
		// "Sec-Fetch-Dest":            "document",
		// "Sec-Fetch-Mode":            "navigate",
		// "Sec-Fetch-Site":            "none",
		// "Upgrade-Insecure-Requests": "1",
		"User-Agent": "Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4195.1 Mobile Safari/537.36",
	}
	DouyinDownloadHeaders = map[string]string{
		"accept":          "*/*",
		"accept-encoding": "identity;q=1, *;q=0",
		"accept-language": "zh-CN,zh;q=0.9,ja;q=0.8,en;q=0.7,zh-TW;q=0.6,de;q=0.5,fr;q=0.4,ca;q=0.3,ga;q=0.2",
		"range":           "bytes=0-",
		"sec-fetch-dest":  "video",
		"sec-fetch-mode":  "no-cors",
		"sec-fetch-site":  "cross-sit",
		"user-agent":      "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1",
	}
	KuaishouDownloadHeaders = map[string]string{
		"accept":          "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
		"accept-encoding": "gzip, deflate, br",
		// "host": "txmov2.a.kwimgs.com",
		// "range": "bytes=0-",
		// "sec-fetch-dest": "video",
		// "sec-fetch-mode": "no-cors",
		// "sec-fetch-site": "cross-sit",
		"Upgrade-Insecure-Requests": "1",
		"user-agent":                "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1",
	}
	KuaishouAuthorHeaders = map[string]string{
		//"accept":          "*/*",
		//"accept-encoding": "gzip, deflate, br",
		"Content-Type":   "application/json; charset=utf-8",
		"Host":           "live.kuaishou.com",
		"Origin":         "https://live.kuaishou.com",
		"Sec-Fetch-Mode": "cors",
		"Sec-Fetch-Site": "same-origin",
		//"Cookie":         "did=web_529ef8673fff419c9f0a0638c05268ca; kpf=PC_WEB; kpn=KUAISHOU_VISION; clientid=3; didv=1647234941000; client_key=65890b29; ktrace-context=1|MS43NjQ1ODM2OTgyODY2OTgyLjEzMTU0MTMyLjE2NDgxNzQxNzEzNzQuMTU2OTA4|MS43NjQ1ODM2OTgyODY2OTgyLjM3Njg1MzQ4LjE2NDgxNzQxNzEzNzQuMTU2OTA5|0|graphql-server|webservice|false|NA",
		"user-agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1",
	}
	SpecialCharacterMask = []string{
		"》", "》", "，", "\n", ":", "<", ">",
	}
	XiGuaHearders = g.MapStrStr{
		"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36 ",
		"cookie":     "MONITOR_WEB_ID=9a341eeb-c59e-4b8a-9b87-a38b2441901d; ttcid=d944469f53974b02a9a365ee358b7dfb36; _tea_utm_cache_1768={%22utm_source%22:%22copy_link%22%2C%22utm_medium%22:%22android%22%2C%22utm_campaign%22:%22client_share%22}; _tea_utm_cache_1300={%22utm_source%22:%22copy_link%22%2C%22utm_medium%22:%22android%22%2C%22utm_campaign%22:%22client_share%22}; _tea_utm_cache_2285={%22utm_source%22:%22copy_link%22%2C%22utm_medium%22:%22android%22%2C%22utm_campaign%22:%22client_share%22}; ttwid=1%7C6KChJ9YF1OvKchyYXNBxOJm4lVdj3-9wgU6GwZjJIwo%7C1648888830%7C1398297ef8eb455cccb4437b8adf8c3e209915ae95c7b4a8895cc17b0b4ac1a1; __ac_nonce=0624ce95f008ff9a928bf; __ac_signature=_02B4Z6wo00f01i7egJgAAIDDTdRA82vj0I4u-oQAAOoJM15nZjC.NE6pVLzrN8YDKGznDIys3WofX4nYwnJb3G4fJAKo72AFxBhqMy2bHWQm6j0EjoWbc9zYbQkoE9H5ImZH.K.d1he.pp9T47; ixigua-a-s=1; support_webp=true; support_avif=true; msToken=eOy5eEvySfp_2RHIq7IY0VLP6WM5-GUgk3WkrTUc-AclwskEkR1AsZYGq5ccLGz44yfuCzV81jQd2ecufDQMO9jHxB1ylnpyXIkEJAcwdRN5dHN6Eyn5NY6yuDstkt0=; tt_scid=VYZoh.2t14RlyP5wRyZmCimSn8YgFec6IBISSw9XnUhF-ixiRFEWpuQrwIwtf4yP2b33",
	}
)

//分析完成之后返回的数据
// type AnalysisUrlRes struct {
// 	Id             int    `json:"id"`
// 	Source         string `json:"source"`
// 	NowatermarkUrl string `json:"nowatermark_url"`
// 	Title          string `json:"title"`
// 	Url            string `json:"url"`
// }

type GatherService interface {
	GetPrefixPattern() string
	MakeUrl(string) string
	Fetch(context.Context, string, chan interface{}) *entity.GatherUrls
	GatherByAuthor(context.Context, string) []*entity.GatherUrls
	Download(context.Context, string) (string, error)
	GetUrl(string) string
}
